/**
 * Copyright (c) 2010 Moogene
 * All rights reserved
 *
 * This software is the confidential and proprietary information of Moogene.
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into
 * with Moogene
 */
package com.moogene.android.engine.action;

/**
 * @author Song, jiawei
 * 
 */
public class ActGestureEvent {
	public final static int TYPE_GESTURE_INVALID = -1;

	// should be larger than TYPE_TOUCH_MOVE
	public final static int TYPE_GESTURE_CIRCLE = 12;
	private final static String STR_TYPE_GESTURE_CIRCLE = "circle";
	public final static int TYPE_GESTURE_HOOK = 13;
	private final static String STR_TYPE_GESTURE_HOOK = "hook";
	public final static int TYPE_GESTURE_WAVE = 14;
	private final static String STR_TYPE_GESTURE_WAVE = "wave";
	
	private int mType;

	private static int[] sTypeGestrues = { TYPE_GESTURE_CIRCLE,
			TYPE_GESTURE_HOOK, TYPE_GESTURE_WAVE };
	private static String[] sStrTypeGestrues = { STR_TYPE_GESTURE_CIRCLE,
			STR_TYPE_GESTURE_HOOK, STR_TYPE_GESTURE_WAVE };
	private static int sReadyGestureType = TYPE_GESTURE_INVALID;

	private static ActGestureEvent sActGestureEvent;
	
	private ActGestureEvent(){

	}
	
	public static ActGestureEvent getInstance(){
		if(sActGestureEvent == null){
			sActGestureEvent = new ActGestureEvent();
		}
		return sActGestureEvent;
	}
	
	public static void triggerGesture(String actionName) {
		for (int i = 0; i < sTypeGestrues.length; i++) {
			if (sStrTypeGestrues[i].compareToIgnoreCase(actionName) == 0) {
				sReadyGestureType = sTypeGestrues[i];
				return;
			}
		}
		// throw new IllegalArgumentException("Unknown gesture: " + actionName);
	}

	/**
	 * @return true if a gesture is made.
	 */
	boolean detectGesture() {
		if (sReadyGestureType != TYPE_GESTURE_INVALID) {
			mType = sReadyGestureType;
			sReadyGestureType = TYPE_GESTURE_INVALID;
			return true;
		}
		return false;
	}
}
